import React, { Component, ComponentClass } from 'react';
import Taro from '@tarojs/taro';
import {View} from '@tarojs/components';
import {GetRequest,vcmonitor} from "../../utils/tools";
import {h5Wx} from "../../utils/h5.service";
import GzhAuth from "../../components/gzh-auth/gzh-auth"

type PageOwnProps = {}
type PageState = {
}
class DetailWeb extends Component {
    state: {
      frist:boolean

    } = {
      frist:false
    }

    async UNSAFE_componentWillMount() {
      if(process.env.TARO_ENV==='h5'){
        await h5Wx.getConfig()
      }
        const {path,appId} = Taro.getCurrentInstance().router.params;
        Taro.navigateToMiniProgram({
          appId,
          path,
          extraData: {

          },
          envVersion: 'release',
          success(res) {
            // 打开成功

          },
          fail(res){
            Taro.switchTab({
              url: '/pages/index/index'
            })
          }
        })
    }

  async componentDidShow() {
      vcmonitor(this)
      if(this.state.frist){
        Taro.navigateBack({
          delta:1
        })
      }
  }
  async componentDidHide() {
    this.setState({
      frist:true
    })}

    render() {

        return (
          <View className='otherRoot'>
            <GzhAuth />
          </View>
        )
    }
}

export default DetailWeb as ComponentClass<PageOwnProps, PageState>;
